'''
https://leetcode-cn.com/problems/maximum-depth-of-n-ary-tree/
忽略深度优先遍历
BFS的话思路很简单,做一个层次遍历就OK了
利用元组来记录当前node节点的深度,每次有Children的时候深度+1
dep就是所有深度里的最大深度
'''

from collections import deque
class Node:
    def __init__(self, val=None, children=None):
        self.val = val
        self.children = children


class Solution:
    def maxDepth(self, root: 'Node') -> int:
        queue = deque()
        if root:
            queue.append((1, root))
        dep = 0

        while len(queue) != 0:
            currentDep, treeNode = queue.popleft()
            if treeNode:
                dep = max(currentDep, dep)
                for t in [] if not treeNode.children else treeNode.children:
                    queue.append((currentDep+1, t))
        return dep

